import request from '@/utils/request'
// import qs from 'qs'

// 双机热备

// 应用配置
export function setHotMachineInfo (params) {
  var data = fromData(params)
  return request({
    url: '/hot/setInfo',
    method: 'post',
    data
  })
}

// 清空配置信息
export function cleanHotMachineInfo (params) {
  var data = fromData(params)
  return request({
    url: '/hot/cleanInfo',
    method: 'post',
    data
  })
}

// 热备开启关闭
export function setHotMachineSwitch (params) {
  var data = fromData(params)
  return request({
    url: '/hot/switch',
    method: 'post',
    data
  })
}

// 获取主备状态
export function getHotMachineStatus (params) {
  var data = fromData(params)
  return request({
    url: '/hot/getStatus',
    method: 'post',
    data
  })
}

// 获取热备程序状态
export function getHotMachineRunStatus (params) {
  var data = fromData(params)
  return request({
    url: '/hot/getRunStatus',
    method: 'post',
    data
  })
}

// 获取配置信息
export function getHotMachineInfo (params) {
  var data = fromData(params)
  return request({
    url: '/hot/getInfo',
    method: 'post',
    data
  })
}

// 虚拟静态路由

// 获取ipv4静态路由信息
export function getIpv4List (params) {
  var data = fromData(params)
  return request({
    url: '/hot/getipv4',
    method: 'post',
    data
  })
}

// 添加ipv4虚拟路由
export function addIpv4 (params) {
  var data = fromData(params)
  return request({
    url: '/hot/addIpv4',
    method: 'post',
    data
  })
}

// 删除ipv4虚拟路由
export function delIpv4 (params) {
  var data = fromData(params)
  return request({
    url: '/hot/delIpv4',
    method: 'post',
    data
  })
}

// 获取ipv6静态路由信息
export function getIpv6List (params) {
  var data = fromData(params)
  return request({
    url: '/hot/getipv6',
    method: 'post',
    data
  })
}

// 添加ipv6虚拟路由
export function addIpv6 (params) {
  var data = fromData(params)
  return request({
    url: '/hot/addIpv6',
    method: 'post',
    data
  })
}

// 删除ipv6虚拟路由
export function delIpv6 (params) {
  var data = fromData(params)
  return request({
    url: '/hot/delIpv6',
    method: 'post',
    data
  })
}

// 实时同步开关
export function hotSwitchConfigure (params) {
  var data = fromData(params)
  return request({
    url: '/hot/switchConfigure',
    method: 'post',
    data
  })
}

// 网络管理及安全策略子模块展示
export function showMode (params) {
  var data = fromData(params)
  return request({
    url: '/hot/showMode',
    method: 'post',
    data
  })
}

// 接收端cli展示
export function showConfigure (params) {
  var data = fromData(params)
  return request({
    url: '/hot/showConfigure',
    method: 'post',
    data
  })
}

// 获取实时同步开关状态
export function getConfigureStatus (params) {
  var data = fromData(params)
  return request({
    url: '/hot/getConfigureStatus',
    method: 'post',
    data
  })
}

// 配置对比
export function hotContrast (params) {
  var data = fromData(params)
  return request({
    url: '/hot/contrast',
    method: 'post',
    data
  })
}

// 获取网络管理及安全策略子模块对比状态
export function showSNStatus (params) {
  var data = fromData(params)
  return request({
    url: '/hot/showSNStatus',
    method: 'post',
    data
  })
}

// 修改网络管理及安全策略子模块对比状态
export function setSNStatus (params) {
  var data = fromData(params)
  return request({
    url: '/hot/setSNStatus',
    method: 'post',
    data
  })
}

// 获取实时同步开关灯状态
export function getConfigureSendStatus (params) {
  var data = fromData(params)
  return request({
    url: '/hot/getConfigureSendStatus',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
